package lynch.map 
{
	import flash.events.Event;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import lynch.display.Container;
	import lynch.net.loading.ResourceLoader;
	import starling.core.RenderSupport;
	import starling.display.Image;
	import starling.display.Quad;
	import starling.textures.ConcreteTexture;
	import starling.textures.SubTexture;
	import starling.textures.Texture;
	
	/**
	 * ...
	 * @author 小痛
	 */
	public class MiniMap extends Container 
	{
		private var img:Image;
		private var subTex:SubTexture;
		private var helpRect:Rectangle = new Rectangle(0, 0, 200, 200);
		
		public function MiniMap() 
		{
			super();
		}
		
		/**
		 * update the position of mini map
		 * @param	p
		 */
		public function updateMiniMapPos(p:Point):void
		{
			helpRect.x = p.x;
			helpRect.y = p.y;
			
			if (subTex)
				subTex.setClipping(helpRect);
		}
		
		public function setBounds(w:int, h:int):void
		{
			helpRect.width = w;
			helpRect.height = h;
			
			if (subTex)
				subTex.setClipping(helpRect);
		}
		
		public function updateInfo(texture:Texture):void
		{
			subTex = new SubTexture(texture, helpRect, true);
			
			if (img)
			{
				img.texture = texture
			} else {
				img = new Image(subTex);
				addChildAt(img, 0);
			}
		}
		
		override public function render(support:RenderSupport, parentAlpha:Number):void 
		{
			super.render(support, parentAlpha);
		}
	}
}